/*
 * File:   estat_main.c
 * Author: oddi
 *
 * Created on January 20, 2010, 11:38 AM
 */

#include "inc/core/particles.h"
#include "inc/core/mover1d.h"
#ifndef _GLOBAL_DEFINITIONS_H
#include "inc/core/global_definitions.h"
#endif

#include "time.h"



#include "stdio.h"


int main(int argc, char** argv)
{
	unsigned long i = 0;
	particles_set set;
	ucgrid1d grid;
	FILE* to;

	mover1d* mover =  NULL;

	particle_initialize_particle_set(&set, NPARTICLES, ELECTRON_CHARGE, ELECTRON_MASS);

	mover = mover1d_setup_mover();
	struct tm t1;
	struct tm t2;

	particle_distrubute_particles_set_pos_uniform_cuda(&set, X, MINZ, MAXZ);
	particle_distrubute_particles_set_pos_uniform_cuda(&set, Y, MINZ, MAXZ);
	particle_distrubute_particles_set_pos_uniform_cuda(&set, Z, MINZ, MAXZ);
	particle_distribute_particle_set_speed_maxwell_cuda(&set, SIGMA, VX);
	particle_distribute_particle_set_speed_maxwell_cuda(&set, SIGMA, VY);
	particle_distribute_particle_set_speed_maxwell_cuda(&set, SIGMA, VZ);
	
	mover1d_backtracing(mover, &set, -0.5*DT);
	time_t start = time (&t1);
	for (i = 0; i < CYCLES; i++)
	{
		//mover1d_dump_E_field_into_file(mover, HOMEDIR, i, 0, L, 0.01, i*DT);
		mover1d_advance(mover, &set, DT);
		mover1d_postprocessing(mover, &set, 0, L, SIGMA);
		//particle_dump_particles_pos_into_file_cuda(&set, HOMEDIR, i, 50, -1);
		particle_calculate_trenergy_distribution_function_cuda_omp(&set, HOMEDIR, i, 53, 0.1, 100);
	}
	time_t end = time (&t2);
	mover1d_clear_mover(mover);
	printf("time: %u s\n", t2.tm_sec -t1.tm_sec );
	return 0;
}
